<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-09 10:07:06
 * @LastEditTime: 2019-10-17 14:13:05
 * @LastEditors: Please set LastEditors
 -->
<template>
  <div class="vx">
    <div class="header">
      <div @click="histry">
        <img src="../assets/histry.png">
        返回
      </div>
      <span class="reg" style="margin-left:-0.3rem;">添加微信号</span>
      <span class="log"></span>
    </div>
    <div class="con">
        <input type="text" placeholder="请输入微信号" v-model="vx" @keyup="keyu">
        <div :class="baocun?'text2':'text3'" @click="bao_cun">保存</div>
    </div>
  </div>
</template>

<script>
import { check_login } from "../api/api.js";
export default {
  name: "vx",
  data() {
    return {
      vx: "",
      baocun:true,
      phone:''
    };
  },
  mounted() {
    if (sessionStorage.getItem("mobile") != null) {
      this.phone = JSON.parse(sessionStorage.getItem("mobile"));
    }
    check_login({
      data: {
        mobile: this.phone
      }
    }).then(res => {
      if (res.data.code == 11001) {
      } else if (res.data.code == 11000) {
        this.$toast("未登录，请重新登录");
        this.$router.push("/");
      }
    });
  },
  created(){
  },
  watch: {},
  methods: {
    // 返回上一层
    histry() {
      this.$router.go(-1);
    },
    keyu(){
        if(this.vx.length>=6){
            this.baocun=false
        }else{
            this.baocun=true
        }
    },
    // 保存备用手机号
    bao_cun(){
        if(this.baocun==false){
            sessionStorage.setItem("mlbb_vx", JSON.stringify(this.vx));
            this.$toast('保存成功')
            this.$router.push('/persona')
        }
    },
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.vx {
  height: 100vh;
  background: #fff;
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 0.5rem;
    line-height: 0.5rem;
    padding: 0 0.15rem;
    border-bottom: 0.01rem solid #eee;
    div {
      display: flex;
      justify-content: left;
      align-items: center;
      color: #979797;
      font-size: 0.14rem;
      img {
        height: 0.16rem;
        width: 0.08rem;
        margin-right: 0.08rem;
      }
    }
    .reg {
      font-size: 0.18rem;
      color: #1a2533;
      font-weight: 500;
    }
    .log {
      font-size: 0.14rem;
      color: #e82716;
      font-weight: bold;
    }
  }
  .con{
      padding: 0 0.15rem;
      input {
        margin-top:0.2rem;
        border: none;
        border-bottom: 0.01rem solid #eee;
        width:100%;
        padding-bottom: 0.15rem;
        color:#1A2533;
        font-size: 0.16rem;
      }
      input::-webkit-input-placeholder {
        color: #CCCCCC;
        font-size: 0.16rem;
      }

      input:-moz-placeholder {
        color: #CCCCCC;
        font-size: 0.16rem;
      }

      input::-moz-placeholder {
        color: #CCCCCC;
        font-size: 0.16rem;
      }

      input:-ms-input-placeholder {
        color: #CCCCCC;
        font-size: 0.16rem;
      }
      div{
          height:0.47rem;
          width: 100%;
          font-size: 0.18rem;
          border-radius: 0.02rem;
          line-height: 0.47rem;
          text-align: center;
          margin-top:0.26rem;
          color:#FFFFFF;
      }
      .text2{
          background: #A9A9A9;
      }
      .text3{
        //   color: 
        background: -webkit-linear-gradient(left, #E82716, #FC6565);
        background: -o-linear-gradient(right, #E82716, #FC6565);
        background: -moz-linear-gradient(right, #E82716, #FC6565);
        background: linear-gradient(to right, #E82716, #FC6565);
      }
  }
}
</style>
